<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>编辑个人资料</title>
    <script src="../js/jquery-3.3.1.min.js"></script>
    <script src="https://unpkg.com/coco-message/coco-message.min.js"></script>
    <link rel="stylesheet" href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
        body{
            user-select: none;
        }
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            margin-top: 65px;
            display: flex;
            justify-content: center;
        }
        .box-content{
            width: 80%;
            margin-top: 10px;
            background-color: #f8f8fa;
            margin-bottom: 20px;
        }
        .box-content-top{
            height: 150px;
        }
        .box-content-bottom{
            /*height: calc(100% - 150px);*/
            background-color: white;
            display: flex;
            padding-bottom: 100px;
        }
        .photo-css{
            margin: -60px 0 0 35px;
            display: inline-block;
            width: 140px;
            height: 140px;
            /*background-image: url("");*/
            background-size: 140px 140px;
        }
        .custom-button {
            background-color: #000000;
            border: none;
            cursor: pointer;
            height: 140px;
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0.5;
        }
        .content{
            width: calc(100% - 175px);
            margin: 0 30px;
        }
        .form{
            border-bottom: 1px solid #ebeced;
            padding: 30px 0;
            display: flex;
        }
        .form label{
            font-weight: 600;
            display: flex;
            align-items: center;
            position: absolute;
        }
        .form-icon{
            border: none;
            background-color: transparent;
            font-size: 15px;
            color: #09408e;
        }
        #backMyHomePage{
            text-decoration: none;
            color: #bbb9b9;
        }
        input[value='保存']{
            background-color: #0066ff;
            color: white;
            margin-right: 5px;
        }
        .btn-css{
            border: none;
            outline: none;
            width: 65px;
            height: 35px;
            border-radius: 4px;
        }
        .btn-css:hover{
            cursor: pointer;
            border: none;
            outline: none;
            width: 65px;
            height: 35px;
            border-radius: 4px;
        }
        input[value='取消']{
            background-color: white;
            color: #797979;
            margin-right: 5px;
            border: 1px solid #aeaeae;
            margin-right: 5px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box-content">
            <div class="box-content-top"></div>
            <div class="box-content-bottom">
                <div class="photo-css" >
                    <form id="forms" style="display: none">
                        <input type="file" name="file" id="fileInput" style="display: none"> <!-- 隐藏原始按钮 -->
                    </form>
                    <div class="custom-button">
                        <div id="uploadDiv" style="color: white;display: flex;flex-direction: column;align-items: center;">
                            <i class="fa fa-camera" style="font-size: 25px;margin-bottom: 13px;"></i>
                            修改我的头像
                        </div>
                    </div>
                </div>
                <div class="content">
                    <div style="line-height: 60px;padding-top: 20px;display: flex;flex-direction: row;">
                        <div id="username-div" style="width: 640px;">
                            <div id="updateName-from" style="display: none">
                                <label style="font-weight: 600;display: flex;align-items: center;position: absolute;">用户名</label>
                                <div style="padding: 15px 64px 0 140px;width: 545px ">
                                    <label style="width: 420px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: 34px;">
                                        <input id="username1" name="username" type="text" value="" style="width: 98%;border: none;outline: none;font-size: 15px;color: #191b1f;">
                                    </label>
                                    <div style="margin-top: 20px;">
                                        <input type="button" id="updateName-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateName-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                            </div>
                            <div id="nameShow" style="display: block">
                                <span style="font-weight: 700;font-size: 23px;" id="usernaem"></span>
                                <button id="updateUserName" style="border: none;background-color: transparent;font-size: 15px;color: #09408e;margin-left: 30px;">
                                    <i class="fa fa-pencil"></i>
                                    修改
                                </button>
                            </div>
                        </div>
                        <a href="personalPage.jsp" target="menuFrame" id="backMyHomePage" style="float: right;">
                            返回我的主页
                            <i class="fa fa-angle-right"></i>
                        </a>
                    </div>
                    <div>
                        <form class="form">
                            <label>性别</label>
                            <div id="sex-div" style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateSex-div" style="display: none">
                                    <div style="height: 50px;">
                                        <input type="radio" id="sex1" name="sex" value="男" style="margin: 0 5px;">男
                                        <input type="radio" id="sex2" name="sex" value="女" style="margin: 0 5px 0 20px;">女
                                    </div>
                                    <div>
                                        <input type="button" id="updateSex-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateSex-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="sexShow" style="display: flex;">
                                    <span id="sex-span" style="margin-right: 5px"></span>
                                    <button id="updateSex"  class="form-icon">
                                        <i class="fa fa-pencil"></i>
                                        修改
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>一句话介绍</label>
                            <div id="introduce-div" style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateIntroduce-div" style="display: none">
                                    <label style="width: 420px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: 34px;">
                                        <input id="introduce" type="text" value="" style="width: 98%;border: none;outline: none;font-size: 15px;color: #191b1f;">
                                    </label>
                                    <div style="padding-top: 55px;">
                                        <input type="button" id="updateIntroduce-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateIntroduce-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="introduceShow" style="display: flex">
                                    <span id="introduce-span" style="margin-right: 5px"></span>
                                    <button id="updateintroduce" class="form-icon">
                                        <i class="fa fa-pencil"></i>
                                        修改
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>居住地</label>
                            <div style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateResidence-div" style="display: none">
                                    <label style="width: 230px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: 34px;">
                                        <input id="residence" type="text" value="" placeholder="添加居住地" style="width: 98%;border: none;outline: none;font-size: 15px;color: #191b1f;">
                                    </label>
                                    <div style="padding-left: 270px;">
                                        <input type="button" id="updateResidence-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateResidence-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="residenceShow" style="display: flex">
                                    <span id="residence-span" style="margin-right: 5px"></span>
                                    <button id="updateResidence" class="form-icon">
                                        <i class="fa fa-plus-circle"></i>
                                        添加居住地
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>所在行业</label>
                            <div style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateVocation-div" style="display: none">
                                    <label>
                                        <select id="vocation-sel" style="width: auto;height: 34px;"></select>
                                    </label>
                                    <div style="padding-left: 270px;">
                                        <input type="button" id="updateVocation-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateVocation-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="vocationShow" style="display: flex">
                                    <span id="vocation-span" style="margin-right: 5px"></span>
                                    <button id="updateVocation" class="form-icon">
                                        <i class="fa fa-pencil"></i>
                                        请填写行业信息
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>职业经历</label>
                            <div style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateprofessionalHistory-div" style="display: none">
                                    <label style="width: 230px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: 34px;">
                                        <input id="professionalHistory" type="text" value="" placeholder="公司或组织名称" style="width: 98%;border: none;outline: none;font-size: 15px;color: #191b1f;">
                                    </label>
                                    <div style="padding-left: 270px;">
                                        <input type="button" id="updateProfessionalHistory-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateProfessionalHistory-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="professionalHistoryShow" style="display: flex">
                                    <span id="professionalHistory-span" style="margin-right: 5px"></span>
                                    <button id="updateProfessionalHistory" class="form-icon">
                                        <i class="fa fa-plus-circle"></i>
                                        添加职业经历
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>教育经历</label>
                            <div style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateEducationExperience-div" style="display: none">
                                    <label style="width: 230px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: 34px;">
                                        <input id="educationExperience" type="text" value="" placeholder="公司或组织名称" style="width: 98%;border: none;outline: none;font-size: 15px;color: #191b1f;">
                                    </label>
                                    <div style="padding-left: 270px;">
                                        <input type="button" id="updateEducationExperience-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateEducationExperience-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="educationExperienceShow" style="display: flex">
                                    <span id="educationExperience-span" style="margin-right: 5px"></span>
                                    <button id="updateEducationExperience" class="form-icon">
                                        <i class="fa fa-plus-circle"></i>
                                        添加教育经历
                                    </button>
                                </div>
                            </div>
                        </form>
                        <form class="form">
                            <label>个人简介</label>
                            <div id="individualResume-div" style="height: 36px;padding: 0 64px 0 140px;width: 545px ">
                                <div id="updateIndividualResume-div" style="display: none">
                                    <label style="width: 525px;border-radius: 3px;border: 1px solid #ebeced;display: flex;justify-content: center;font-size: 14px;height: auto;">
                                        <textarea id="individualResume" rows="5" style="resize: none;width: 99%;border: none;outline: none;font-size: 15px;color: #191b1f;"></textarea>
                                    </label>
                                    <div style="padding-top: 105px;">
                                        <input type="button" id="updateIndividualResume-btn" class="btn-css" value="保存">
                                        <input type="button" id="updateIndividualResume-cancel-btn" class="btn-css" value="取消">
                                    </div>
                                </div>
                                <div id="individualResumeShow" style="display: flex">
                                    <span id="individualResume-span" style="margin-right: 5px;max-width: 300px";text-overflow :ellipsis;></span>
                                    <button id="updateIndividualResume" class="form-icon">
                                        <i class="fa fa-pencil"></i>
                                        修改
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        "use strict";
        <% Object username = session.getAttribute("username");%>

        let userId = 0;
        let userName;
        $(function (){
            selectUser(); //查询当前登录的用户信息

            $.getJSON("../json/industry.json",function(data){
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    let op = $("<option>").val(item.industry_name).html(item.industry_name);
                    $("#vocation-sel").append(op);
                }
            })
        });

        // 用户名
        $("#updateUserName").on("click",function (){
            $("#nameShow").css("display","none");
            $("#updateName-from").css("display","block");
            $("#username1").val($("#usernaem").text());
        });
        $("#updateName-btn").on("click",function (){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "username": $("#username1").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#usernaem").text($("#username1").val());
                        $("#nameShow").css("display","block");
                        $("#updateName-from").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateName-cancel-btn").on("click",function (){
            $("#nameShow").css("display","block");
            $("#updateName-from").css("display","none");
        })

        // 性别
        $("#sexShow").hover(function (){
            if ($("#sex-span").text().trim() === ""){
                $("#updateSex").css("visibility","visible");
            }else {
                $("#updateSex").css("visibility","visible");
            }
        },function (){
            if ($("#sex-span").text().trim() === ""){
                $("#updateSex").css("visibility","visible");
            }else {
                $("#updateSex").css("visibility","hidden");
            }
        })
        $("#updateSex").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#sexShow").css("display", "none");
            $("#updateSex-div").css("display", "block");

            let text = $("#sex-span").text().trim();
            if ($("#sex1").val() == text){
                $("#sex1").attr("checked","true");
            }else if ($("#sex2").val() == text){
                $("#sex2").attr("checked","true");
            }
            $("#sex-div").css("height", "auto");
        })
        $("#updateSex-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "sex": $("input[name='sex']:checked").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#sex-span").text($("input[name='sex']:checked").val());
                        $("#sexShow").css("display","block");
                        $("#updateSex-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateSex-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#sexShow").css("display","block");
            $("#updateSex-div").css("display","none");
            $("#sex-div").css("height","36px");
        })


        // 一句话介绍
        $("#introduceShow").hover(function (){
            if ($("#introduce-span").text().trim() === ""){
                $("#updateintroduce").css("visibility","visible");
            }else {
                $("#updateintroduce").css("visibility","visible");
            }
        },function (){
            if ($("#introduce-span").text().trim() === ""){
                $("#updateintroduce").css("visibility","visible");
            }else {
                $("#updateintroduce").css("visibility","hidden");
            }
        })
        $("#updateintroduce").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#introduceShow").css("display", "none");
            $("#updateIntroduce-div").css("display", "block");

            $("#introduce").val($("#introduce-span").text().trim());
            $("#introduce-div").css("height", "auto");
        })
        $("#updateIntroduce-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "introduce": $("#introduce").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#introduce-span").text($("#introduce").val());
                        $("#introduceShow").css("display","block");
                        $("#updateIntroduce-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateIntroduce-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#introduceShow").css("display","block");
            $("#updateIntroduce-div").css("display","none");
            $("#introduce-div").css("height","36px");
        })

        // 居住地
        $("#residenceShow").hover(function (){
            if ($("#residence-span").text().trim() === ""){
                $("#updateResidence").css("visibility","visible");
            }else {
                $("#updateResidence").css("visibility","visible");
            }
        },function (){
            if ($("#residence-span").text().trim() === ""){
                $("#updateResidence").css("visibility","visible");
            }else {
                $("#updateResidence").css("visibility","hidden");
            }
        })
        $("#updateResidence").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#residenceShow").css("display", "none");
            $("#updateResidence-div").css("display", "block");

            $("#residence").val($("#residence-span").text().trim());
        })
        $("#updateResidence-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "residence": $("#residence").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#residence-span").text($("#residence").val());
                        $("#residenceShow").css("display","block");
                        $("#updateResidence-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateResidence-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#residenceShow").css("display","block");
            $("#updateResidence-div").css("display","none");
            // $("#introduce-div").css("height","36px");
        })

        //所在行业
        $("#vocationShow").hover(function (){
            if ($("#vocation-span").text().trim() === ""){
                $("#updateVocation").css("visibility","visible");
            }else {
                $("#updateVocation").css("visibility","visible");
            }
        },function (){
            if ($("#vocation-span").text().trim() === ""){
                $("#updateVocation").css("visibility","visible");
            }else {
                $("#updateVocation").css("visibility","hidden");
            }
        })
        $("#updateVocation").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#vocationShow").css("display", "none");
            $("#updateVocation-div").css("display", "block");
            let sel = $("#vocation-sel");

            for (let j = 0; j < sel[0].options.length; j++) {
                if (sel[0].options[j].value == $("#vocation-span").text().trim()){
                    sel[0].options[j].selected = true;
                    break;
                }
            }
        })
        $("#updateVocation-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "vocation": $("#vocation-sel").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#vocation-span").text($("#vocation-sel").val());
                        $("#vocationShow").css("display","block");
                        $("#updateVocation-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateVocation-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#vocationShow").css("display","block");
            $("#updateVocation-div").css("display","none");
        })

        //职业经历
        $("#professionalHistoryShow").hover(function (){
            if ($("#professionalHistory-span").text().trim() === ""){
                $("#updateProfessionalHistory").css("visibility","visible");
            }else {
                $("#updateProfessionalHistory").css("visibility","visible");
            }
        },function (){
            if ($("#professionalHistory-span").text().trim() === ""){
                $("#updateProfessionalHistory").css("visibility","visible");
            }else {
                $("#updateProfessionalHistory").css("visibility","hidden");
            }
        })
        $("#updateProfessionalHistory").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#professionalHistoryShow").css("display", "none");
            $("#updateprofessionalHistory-div").css("display", "block");
            $("#professionalHistory").val($("#professionalHistory-span").text().trim());
        })
        $("#updateProfessionalHistory-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "professionalHistory": $("#professionalHistory").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#professionalHistory-span").text($("#professionalHistory").val());
                        $("#professionalHistoryShow").css("display","block");
                        $("#updateprofessionalHistory-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateProfessionalHistory-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#professionalHistoryShow").css("display","block");
            $("#updateprofessionalHistory-div").css("display","none");
        })

        // 教育经历
        $("#educationExperienceShow").hover(function (){
            if ($("#educationExperience-span").text().trim() === ""){
                $("#updateEducationExperience").css("visibility","visible");
            }else {
                $("#updateEducationExperience").css("visibility","visible");
            }
        },function (){
            if ($("#educationExperience-span").text().trim() === ""){
                $("#updateEducationExperience").css("visibility","visible");
            }else {
                $("#updateEducationExperience").css("visibility","hidden");
            }
        })
        $("#updateEducationExperience").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#educationExperienceShow").css("display", "none");
            $("#updateEducationExperience-div").css("display", "block");
            $("#educationExperience").val($("#educationExperience-span").text().trim());
        })
        $("#updateEducationExperience-btn").on("click",function (event){
            window.parent.prohibition();
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "educationExperience": $("#educationExperience").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#educationExperience-span").text($("#educationExperience").val());
                        $("#educationExperienceShow").css("display","block");
                        $("#updateEducationExperience-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateEducationExperience-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#educationExperienceShow").css("display","block");
            $("#updateEducationExperience-div").css("display","none");
        })

        // 个人简介
        $("#individualResumeShow").hover(function (){
            if ($("#individualResume-span").text().trim() === ""){
                $("#updateIndividualResume").css("visibility","visible");
            }else {
                $("#updateIndividualResume").css("visibility","visible");
            }
        },function (){
            if ($("#individualResume-span").text().trim() === ""){
                $("#updateIndividualResume").css("visibility","visible");
            }else {
                $("#updateIndividualResume").css("visibility","hidden");
            }
        })
        $("#updateIndividualResume").on("click", function (event) {
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#individualResumeShow").css("display", "none");
            $("#updateIndividualResume-div").css("display", "block");
            $("#individualResume-div").css("height", "auto");
            $("#individualResume").val($("#individualResume-span").text().trim());
        })
        $("#updateIndividualResume-btn").on("click",function (event){
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                dataType: "json",
                data: {
                    "id": userId,
                    "individualResume": $("#individualResume").val()
                },success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功")
                        $("#individualResume-span").text($("#individualResume").val());
                        $("#individualResumeShow").css("display","block");
                        $("#updateIndividualResume-div").css("display","none");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        })
        $("#updateIndividualResume-cancel-btn").on("click",function (event){
            event.preventDefault(); //阻止浏览器执行默认行为（例如页面刷新）
            $("#individualResumeShow").css("display","block");
            $("#updateIndividualResume-div").css("display","none");
            $("#individualResume-div").css("height", "36px");
        })


        let uploadDiv = $("#uploadDiv");
        let fileInput = $("#fileInput");

        uploadDiv.on("click",function (){
            fileInput.click(); //触发文件输入框点击事件
        });

        // 添加文件输入框变化事件监听器
        fileInput.on('change', function (event) {
            window.parent.prohibition();
            // 处理选择的文件
            console.log(this.files[0].name)
            let aa = new FormData($("#forms")[0]);
            aa.append("id",userId);
            $.ajax({
                async: true,
                type: "post",
                url: "http://localhost:8080/zhihu1/user?ac=updateUser",
                processData: false,
                contentType: false,
                dataType: "json",
                data: aa,
                success:function (data){
                    if (data.data){
                        window.parent.cocoMessage.info("修改成功");
                        window.parent.$("#userImg").attr("src",data.data.img);
                        $(".photo-css").css("background-image","url("+data.data.img+")");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        });
        // 查询当前登录的用户信息
        function selectUser(){
            $.ajax({
                type:"post",
                url:"http://localhost:8080/zhihu1/user?ac=queryInterest",
                dataType: "json",
                data:{
                    username: "<%=username%>"
                },success:function (data){
                    userId = data.data[0].user.id;
                    userName = data.data[0].user.userName;
                    $(".photo-css").css("background-image","url("+data.data[0].user.img+")");
                    $("#usernaem").text(data.data[0].user.userName);
                    $("#sex-span").text(data.data[0].user.sex);
                    $("#introduce-span").text(data.data[0].user.introduce);
                    $("#residence-span").text(data.data[0].user.residence);
                    $("#vocation-span").text(data.data[0].user.vocation);
                    $("#professionalHistory-span").text(data.data[0].user.professionalHistory);
                    $("#educationExperience-span").text(data.data[0].user.educationExperience);
                    $("#individualResume-span").text(data.data[0].user.individualResume);

                    //判断性别是否为空
                    if ($("#sex-span").text().trim() === ""){
                        $("#updateSex").css("visibility","visible");
                    }else {
                        $("#updateSex").css("visibility","hidden");
                    }

                    if ($("#introduce-span").text().trim() === ""){
                        $("#updateintroduce").css("visibility","visible");
                    }else {
                        $("#updateintroduce").css("visibility","hidden");
                    }

                    if ($("#residence-span").text().trim() === ""){
                        $("#updateResidence").css("visibility","visible");
                    }else {
                        $("#updateResidence").css("visibility","hidden");
                    }

                    if ($("#vocation-span").text().trim() === ""){
                        $("#updateVocation").css("visibility","visible");
                    }else {
                        $("#updateVocation").css("visibility","hidden");
                    }

                    if ($("#professionalHistory-span").text().trim() === ""){
                        $("#updateProfessionalHistory").css("visibility","visible");
                    }else {
                        $("#updateProfessionalHistory").css("visibility","hidden");
                    }

                    if ($("#educationExperience-span").text().trim() === ""){
                        $("#updateEducationExperience").css("visibility","visible");
                    }else {
                        $("#updateEducationExperience").css("visibility","hidden");
                    }

                    if ($("#individualResume-span").text().trim() === ""){
                        $("#updateIndividualResume").css("visibility","visible");
                    }else {
                        $("#updateIndividualResume").css("visibility","hidden");
                    }
                },error:function (error){
                    console.log(error);
                }
            })
        }

        $("html").on("click",function (event){
            window.parent.$("#myDropdown").css("display","none");
            window.parent.close()
            window.parent.$(".dropdown-news").css("display","none");
        })
    </script>
</body>
</html>
